import {
  AUDIT_STATUS
} from '@/pages/supplier/constants/returnVisteManage'
import {
  INSPECTION_CLASSIFY_OPTIONS,
  SUPPLIER_CLASSIFY_OPTIONS
} from '../../constants'
// 报告评价 - 评分选项
const MARK_OPTIONS = [
  {
    label: '完成考察目的目标值',
    value: '10',
  },
  {
    label: '未达目标值有改善',
    value: '20',
  },
  {
    label: '无任何改善',
    value: '30',
  },
]
// 评分未达目标值 分值关系
const SCORE_MAPS = {
  '瓶颈': 0.75,
  '战略': 0.7,
  '核心': 0.6,
  '一般': 0.5,
}
// 考察报告列表
const FORM_ITEM_LIST = [
  {
    prop: 'planCode',
    label: '计划编号',
    type: 'input'
  },
  {
    prop: 'planName',
    label: '计划名称',
    type: 'input'
  },
  {
    prop: 'supplierCode',
    label: '供应商代码',
    type: 'input'
  },
  {
    prop: 'supplierName',
    label: '供应商名称',
    type: 'input',
  },
  // visitTimeStart visitTimeEnd
  {
    prop: 'visitTime',
    label: '拜访时间',
    type: 'datePicker',
    valueFormat: 'yyyy-MM-dd'
  },
  {
    prop: 'inspector',
    label: '考察人',
    type: 'input',
  },
  // inspectCompleteTimeStart inspectCompleteTimeEnd
  {
    prop: 'inspectCompleteTime',
    label: '考察完成时间',
    type: 'datePicker',
    valueFormat: 'yyyy-MM-dd'
  },
  // reportTimeStart reportTimeEnd
  {
    prop: 'reportTime',
    label: '报告录入时间',
    type: 'datePicker',
    valueFormat: 'yyyy-MM-dd'
  },
  {
    prop: 'status',
    label: '审批状态',
    type: 'select',
    clearable: true,
    options: AUDIT_STATUS,
  },
  {
    prop: 'supplierClassify',
    label: '供应商分类',
    type: 'select',
    clearable: true,
    options: SUPPLIER_CLASSIFY_OPTIONS,
  },
  {
    prop: 'inspectionClassify',
    label: '考察分类',
    type: 'select',
    options: INSPECTION_CLASSIFY_OPTIONS,
  },
  {
    prop: 'callbackTime',
    label: '审批完成时间',
    type: 'datePicker',
    valueFormat: 'yyyy-MM-dd'
  },
]
const initTableColumns = (parent) => {
  return [
    {
      title: '计划编号',
      key: 'planCode'
    },
    {
      title: '计划名称',
      key: 'planName'
    },
    {
      title: '供应商代码',
      key: 'supplierCode'
    },
    {
      title: '供应商名称',
      key: 'supplierName',
    },
    {
      title: '管理区域',
      key: 'managementAreaName',
    },
    {
      title: '本年进货额',
      key: 'yearPurchaseAmount'
    },
    {
      title: '考察目的',
      key: 'target'
    },
    {
      title: '拜访时间',
      key: 'visitTime'
    },
    {
      title: '考察人',
      key: 'inspector'
    },
    {
      title: '业务对接人',
      key: 'businessContactName'
    },
    {
      title: '考察完成时间',
      key: 'inspectCompleteTime'
    },
    {
      title: '报告录入完成时间',
      key: 'reportTime'
    },
    {
      title: '审批状态',
      key: 'status',
      render: (h, { row }) => {
        if (row.status) {
          return <span>{AUDIT_STATUS.find(item => item.value == row.status).label}</span>
        }
      }
    },
    {
      title: '报告编号',
      key: 'reportCode'
    },
    // 1:潜在转合格, 2:合格转潜在, 3:潜在转线索, 4:供应商淘汰, 5:供应商拉黑, 6:修改资质
    {
      title: '后续待办',
      key: 'subsequentBacklogName',
    },
    {
      title: '供应商分类',
      key: 'supplierClassifyName',
    },
    {
      title: '待办说明',
      key: 'backlogExplain'
    },
    //  0未处理, 1未待办， 2已待办
    {
      title: '待办状态',
      key: 'backlogStateName',
    },
    {
      title: '报告评价',
      key: 'reportScroing',
      render: (h, { row, index }) => {
        return <a onClick={ () => { parent.viewReportScroing(row) }}>报告评级</a>
      }
    },
    {
      title: '评价分数',
      key: 'evaluationScore',
    },
    {
      title: '预计完成时间',
      key: 'planCompleteTime'
    },
    {
      title: '审批完成时间',
      key: 'callbackTime'
    },
  ]
}
export {
  MARK_OPTIONS,
  SCORE_MAPS,
  FORM_ITEM_LIST,
  initTableColumns
}
